import StorageUtil from "../Util/StorageUtil";

const { ccclass, property } = cc._decorator;

@ccclass
export default class BaseScene extends cc.Component {

    protected onLoad() {
        // //视图中canvas尺寸812x375
        // console.log("canvas size:", cc.view.getCanvasSize());
        // //视图中窗口可见区域尺寸1385x640
        // console.log("visible Size:", cc.view.getVisibleSize());
        // //设计分辨率960x640
        // console.log("DesignResolutionSize Size:", cc.view.getDesignResolutionSize());
        // //屏幕尺寸812x375
        // console.log("frame size", cc.view.getFrameSize());
        // //当前游戏窗口大小1385x640
        // console.log("winSize:", cc.winSize);
    }

    protected onEnable() {
        cc.game.on(cc.game.EVENT_SHOW, this.onGameShowHandler, this);
        cc.game.on(cc.game.EVENT_HIDE, this.onGameHideHandler, this);
    }

    protected onDisable() {
        cc.game.off(cc.game.EVENT_SHOW, this.onGameShowHandler, this);
        cc.game.off(cc.game.EVENT_HIDE, this.onGameHideHandler, this);
    }

    private onGameShowHandler() {
        console.log("BaseScene.onChangeToGame()===>游戏进入前台~");
    }

    private onGameHideHandler() {
        console.log("BaseScene.onChangeToBack()===>游戏进入后台~");
        StorageUtil.instance.save();
    }
}